package com.xiguaji.tiktok.v1.common.controller;

import com.xiguaji.tiktok.config.Config;
import com.xiguaji.tiktok.v1.BaseController;
import com.xiguaji.tiktok.v1.user.log.Operation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 默认图片
 * @author huangxin
 */
@RestController
@RequestMapping("/defaultImage")
@Api(value = "默认图片",tags = {"默认图片"})
public class DefaultImageController extends BaseController {

    /**
     * config
     */
    @Autowired
    private Config config;

    /**
     * 小图
     */
    private static final int SMALL_IMAGE = 0;

    /**
     * 中图
     */
    private static final int MIDDLE_IMAGE = 1;

    /**
     * 大图
     */
    private static final int LARGE_IMAGE = 2;

    @ApiOperation(value = "获取达人默认头像")
    @GetMapping(value = "blogger/{type}",produces = "application/json;charset=UTF-8")
    @Operation(value = "获取达人默认头像")
    public String getBloggerImageUrl(@PathVariable int type){
        if(MIDDLE_IMAGE == type){
            return config.getBloggerMiddleImageUrl();
        }
        if(LARGE_IMAGE == type){
            return config.getBloggerLargeImageUrl();
        }
        return config.getBloggerSmallImageUrl();
    }

    @ApiOperation(value = "获取商品默认图片")
    @GetMapping(value = "product",produces = "application/json;charset=UTF-8")
    @Operation(value = "获取商品默认图片")
    public String getProductImageUrl(){
        return config.getProductImageSmallUrl();
    }

    @ApiOperation(value = "获取帖子默认封面")
    @GetMapping(value = "media",produces = "application/json;charset=UTF-8")
    @Operation(value = "获取帖子默认封面")
    public String getMediaImageUrl(){
        return config.getMediaImageSmallUrl();
    }
}
